use super::*;

#[derive(Clone, Copy)]
pub struct Table<'a> {
	// fixed32	version	Set to 0x00010000 (1.0).
	pub version: i32,
	// uint16	tupleCount	Flags in high-order 4 bits, count in low-order 12 bits.
	pub tuple_count: u16,
	// uint16	offsetToData	Offset from start of CVT Variations table to the start of the tuple data.
	pub offset_to_data: u16,

	pub data: &'a [u8],
}
impl<'a> Table<'a> {
	pub fn parse(data: &'a [u8]) -> Option<Self> {
		let mut s = Stream::new(data);
		Some(Self {
			version: s.read()?,
			tuple_count: s.read()?,
			offset_to_data: s.read()?,
			data,
		})
	}
}
impl<'a> core::fmt::Debug for Table<'a> {
	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
		f.debug_struct("Table")
			.field("version", &self.version)
			.field("tuple_count", &self.tuple_count)
			.field("offset_to_data", &self.offset_to_data)
			// .field("data", &self.data)
			.finish()
	}
}
